<div xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  xmlns:nxd="http://nuxeo.org/nxweb/document"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:f="http://java.sun.com/jsf/core">

<a4j:outputPanel id="admStatusPanel" layout="block">

 <h:panelGroup rendered="#{isMultiServerInstallation}">
  <h:outputText value="#{messages['label.monitoring.multiserver']}" /><br/>
  <h:outputText value="#{messages['label.monitoring.instanceList']}" /><br/>
  <nxu:repeat var="serverName" value="#{monitoringAction.listNuxeoInstances()}">
   <h:outputText value="#{serverName}" /> <br/>
  </nxu:repeat>
 </h:panelGroup>

 <h:panelGroup rendered="#{!isMultiServerInstallation}">
  <h:outputText value="#{messages['label.monitoring.monoserver']}" /><br/>
 </h:panelGroup>

 <br/>

  <h:dataTable var="status" value="#{monitoringAction.getAdministrativeStatuses()}" class="dataOutput" rendered="#{monitoringAction.editableStatus==null}">
    <h:column>
      <f:facet name="header">
        <h:outputText value="#{messages['label.monitoring.status.label']}" />
      </f:facet>
      <h:outputText value="#{status.label}" />
    </h:column>
    <h:column>
      <f:facet name="header">
      <h:outputText value="#{messages['label.monitoring.status.state']}" />
      </f:facet>
       <h:graphicImage url="/img/state_active.png"
    alt="#{status.state}"  title="#{status.state}" rendered="#{status.isActive()}"/>
       <h:graphicImage url="/img/state_inactive.png"
    alt="#{status.state}" title="#{status.state}" rendered="#{!status.isActive()}"/>
    </h:column>
    <h:column>
      <f:facet name="header">
      <h:outputText value="#{messages['label.monitoring.status.message']}" />
      </f:facet>
      <h:outputText value="#{status.message}" />
    </h:column>
    <h:column>
      <f:facet name="header">
      <h:outputText value="#{messages['label.monitoring.status.description']}" />
      </f:facet>
      <h:outputText value="#{status.description}" />
    </h:column>
    <h:column>
      <f:facet name="header">
      <h:outputText value="#{messages['label.monitoring.status.action']}" />
      </f:facet>

     <h:form>
        <a4j:commandButton  value="#{messages['action.monitoring.edit']}" action="#{monitoringAction.editStatus()}" render="admStatusPanel" styleClass="button">
            <f:param name="serviceIdentifier" value="#{status.serviceIdentifier}" />
        </a4j:commandButton>
     </h:form>

    </h:column>
  </h:dataTable>

  <h:panelGroup rendered="#{monitoringAction.editableStatus!=null}">
    <h:form>
      <h:outputText value="#{messages['label.monitoring.status.currentState']}" />
      <table class="dataOutput">
        <tr><td class="labelColumn"><h:outputText value="#{messages['label.monitoring.status.label']}" /></td>
            <td><h:outputText value="#{monitoringAction.editableStatus.label}"/></td>
        </tr>
        <tr><td class="labelColumn"><h:outputText value="#{messages['label.monitoring.status.state']}" /></td>
            <td><h:outputText value="#{monitoringAction.editableStatus.state}"/></td>
        </tr>
        <tr><td class="labelColumn"><h:outputText value="#{messages['label.monitoring.status.description']}" /></td>
            <td><h:outputText value="#{monitoringAction.editableStatus.description}"/></td>
        </tr>
        <tr><td class="labelColumn"><h:outputText value="#{messages['label.monitoring.status.lastUpdate']}" /></td>
            <td><h:outputText value="#{monitoringAction.editableStatus.modificationDate.time}">
                  <f:convertDateTime type="both" dateStyle="short" timeStyle="short"/>
                </h:outputText>
            </td>
        </tr>
        <tr><td class="labelColumn"><h:outputText value="#{messages['label.monitoring.status.login']}" /></td>
            <td><h:outputText value="#{monitoringAction.editableStatus.userLogin}"/></td>
        </tr>
        <tr><td class="labelColumn"><h:outputText value="#{messages['label.monitoring.status.message']}" /></td>
            <td><h:outputText value="#{monitoringAction.editableStatus.message}"/></td>
        </tr>

      </table>

      <br/><hr/><br/>

      <h:outputText value="#{messages['label.monitoring.status.newState']}" />

      <table class="dataInput">
        <tr>
            <td><h:outputText value="#{messages['label.monitoring.status.message']}"/></td>
            <td><h:inputText value="#{monitoringAction.newStatusMessage}" size="100"/></td>
        </tr>
        <tr>
            <td><h:outputText value="#{messages['label.monitoring.status.state']}" /></td>
            <td>
              <h:selectOneListbox class="dataInputText" size="1" value="#{monitoringAction.newStatusValue}">
                    <f:selectItem itemValue = "active" itemLabel = "#{messages['label.status.active']}"/>
                    <f:selectItem itemValue = "passive" itemLabel = "#{messages['label.status.passive']}"/>
             </h:selectOneListbox>
            </td>
        </tr>
      </table>

      <a4j:commandButton  value="#{messages['action.monitoring.save']}" action="#{monitoringAction.saveStatus()}" render="admStatusPanel" styleClass="button" />
      <a4j:commandButton  value="#{messages['action.monitoring.cancel']}" action="#{monitoringAction.cancelEdit()}" render="admStatusPanel" styleClass="button" />

    </h:form>
  </h:panelGroup>
</a4j:outputPanel>

</div>